<template>
	<view class="">
		<view class="">
			<slideshow :swiperList="swiperList"></slideshow>
		</view>
		<view class="">
			<view class="" style="margin-top: 30rpx;">
				<panel  rightTitle="'" title="个人信息" titleIcon="/static/index/2.png">
					<view class=""
						style="display: flex;align-items: center;justify-content: space-between;margin-top: 20rpx;">
						<view class="" style="display: flex;align-items: center;">
							<view class="">
								<image style="width: 50rpx;height: 50rpx;border-radius: 50%;" :src="userInfo.avatar"
									mode="">
								</image>
							</view>
							<view class="" style="font-size: 35rpx;margin-left: 10rpx;">
								{{userInfo.name}}
							</view>
						</view>
						<view class="" style="width: 1rpx;height: 50rpx;background: #0081ff;">
							
						</view>
						<view class="">
							<view class="" style="margin-top: 20rpx;">
								<view class=""
									style="display: flex;align-items: center;justify-content: space-between;">
									<view class="" style="font-size: 35rpx;">
										下载状态：
									</view>
									<view class=""
										style="font-size: 29rpx;background: #0081ff;color: #fff;padding: 9rpx 26rpx;border-radius: 50rpx;">
										<view class="" v-if="userDate != '已过期' && userDate != ''">
											{{userDate}}
										</view>
										<view class="" v-else>
											已过期
										</view>
									</view>
								</view>
							</view>
						</view>

					</view>
				</panel>
			</view>
		</view>
		
		<view class="">
			<view class="" style="margin-top: 30rpx;">
				<panel  rightTitle="'" title="任务奖励" titleIcon="/static/index/2.png">
					<view class="">
						<view  v-for="(item,index) in awardList" :key="index" class=""
							style=" display: flex;align-items: center;justify-content: space-between;margin-top: 30rpx;">
							<view class="" style="display: flex;align-items: center;">
								<view class="">
									<view class="lg text-gray " :class="item.icon" style="color: #0081ff;font-size: 60rpx;">
										
									</view>
								</view>
								<view class="" style="margin-left: 10rpx;">
									<view class="" style="font-size: 35rpx;">
										{{item.name}}
									</view>
									<view class="" style="color: #bdbab5;">
										{{item.des}}
									</view>
								</view>
							</view>
						
							<view class="">
								<view class="award-centre">
								
									<button @click="getVIPTime(item,index)" :open-type="item.type == 'fx' ?'share':''" class=""
										style="height: 60rpx; line-height: 60rpx;font-size: 29rpx; border:1rpx solid #0081ff;color: #0081ff;border-radius: 50rpx;">
										
										<view class="" >
											去完成
										</view>
									</button>
								</view>
							</view>
								
						</view>
				
					
					</view>
				</panel>
			</view>
		</view>
		
				
		
		
		
		
		<!-- 	<view class="">
			<view class="" style="margin-top: 30rpx;" v-if="advertisingOpen && adUnitIdbanner">
				<panel @more="to2" rightTitleIcon=">" title="热门广告" titleIcon="/static/index/2.png">
					<ad style="width: auto; !important" :unit-id="adUnitIdbanner"></ad>
				</panel>
			</view>
		</view> -->


	</view>
</template>

<script>
	import slideshow from "@/components/common/slideshow.vue"
	import panel from "@/components/common/panel.vue"
	import {
		mixinAdvertising,
		advertisingData
	} from '@/mixin/advertising.js'
	import {
		login
	} from '@/mixin/login.js'
	import {
		advertisingData11
	} from "@/mixin/advertisingData1.js"
	export default {
		mixins: [login, mixinAdvertising, advertisingData11,advertisingData],
		components: {
			slideshow,
			panel
		},
		data() {
			return {
				"awardList":[
					
				],
				userInfo: {},
				userDate1: "",
				swiperList: [],
				currentAwardItem:{},
				userDate:0
			}
		},
		onLoad() {
			this.getBanner()
			this.suanTiem1()
			this.suanTiem()
		},
		async onShow() {
			this.userInfo = uni.getStorageSync('user')
			var vipConfig = uni.getStorageSync('vipConfig')
			if(vipConfig.awardList){
				this.awardList = vipConfig.awardList
				this.awardList.forEach(item=>{
					for(let key in vipConfig){
						if(!item[key] && vipConfig[key] == 1){
							item[key] = vipConfig[key]
						}
					}
					
				})
			}
			await this.getUser()
			this.suanTiem1()
			this.suanTiem()
		},
 		onShareTimeline: function() {
			return {
				title: "这里可以免费短视频去水印下载",
				path: "pages/index/index",
				imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-d34a378b-4b56-477e-8ef5-87e5d263ecd1/289e14d3-0929-4d1b-9af4-c08a40c4b0c2.png',
			};
		},
		onShareAppMessage() {
			setTimeout(()=>{
				this.userUpdate(()=>{
					setTimeout(()=>{
						this.$store.commit('setIsDownload',true)
						var user = uni.getStorageSync('user')
						this.userInfo = user
						this.suanTiem1()
						this.suanTiem()
					})
				},this.currentAwardItem.date,this.currentAwardItem.setData)
			},500)
			return {
				title: '这里可以免费短视频去水印下载',
				path: '/pages/index/index',
				imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-d34a378b-4b56-477e-8ef5-87e5d263ecd1/289e14d3-0929-4d1b-9af4-c08a40c4b0c2.png',
				success: function(res) {
					// 转发成功之后的回调
					console.log(res,'11111111111')
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: function() {
					console.log("22222222222222333333333333")
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: function() {
					console.log("22222222222222")
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
			
		},
		methods: {
			// 看广告获取vip时间
			kanguangao1Btn(){
				this.kanguangao1(()=>{
					setTimeout(()=>{
						var user = uni.getStorageSync('user')
						this.userInfo = user
						this.suanTiem1()
						this.suanTiem()
					})
				},this.currentAwardItem.date,this.currentAwardItem.setData)
			},
			// 获取VIP时间按钮
			getVIPTime(item){
				this.currentAwardItem = item
				console.log(this.currentAwardItem)
				// #ifdef MP-WEIXIN
				if(item.type != 'fx'){
					this.kanguangao1Btn()
				}
				// #endif
				
				// #ifdef APP-PLUS || H5
				this.toGetVip()
				// #endif
				
			},
			suanTiem1() {
				var userInfo = uni.getStorageSync('user')
				if (!userInfo) {
					return
				}

				var date = this.$T.endDate(Number(userInfo.integral))
				this.userDate1 = date
			},
			suanTiem() {
				var userInfo = uni.getStorageSync('user')
				if (!userInfo) {
					return
				}
			
				var date = this.$T.endDate(Number(userInfo.downloadDate))
				this.userDate = date
			},
			async getBanner() {
				var data = await this.$api.getListData({
					dbName: "wx_banner",
					pageIndex: 1,
					pageSize: 10,
					order: {
						name: 'sort',
						type: 'desc'
					}
				})
				this.swiperList = data.data
			}
		}
	}
</script>

<style>
	page {
		background: #bce4fd;
	}

	.award-centre  button {
		background: transparent !important;

	}

	.award-centre  button::after {
		border: none !important;
	}
</style>
